package io.bsly.modules.app.controller;

import io.bsly.common.utils.PageUtils;
import io.bsly.common.utils.R;
import io.bsly.modules.app.entity.localEntity.DyProductEntity;
import io.bsly.modules.app.service.localmaster.DyProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 品名管理
 * @author fys
 */
@Api(tags = "产品管理")
@RestController
@RequestMapping("app/dyproduct")
public class DyProductController {
    @Autowired
    private DyProductService dyProductService;

    /**
     * 列表
     * @param  "map 可传 分页page limit 和  name"
     * 排序   sidx 排序字段   order 指定 asc 或 desc
     */
    @ApiOperation("分页展示")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "产品名称" , dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "page",value = "当前页数" , dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "limit",value = "每页条数" , dataType = "int", paramType = "query")
    })
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> map){
        PageUtils page = dyProductService.queryPage(map);
        return R.ok().put("page", page);
    }


    /**
     * 查询信息
     */
    @ApiOperation(value = "根据id查询")
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		DyProductEntity dyProduct = dyProductService.getById(id);
        return R.ok().put("dyProduct", dyProduct);
    }
}
